import { columns } from "../data";
import Mock from "mockjs";
export const generateFakeData = (rowCount = 10) => {
  const data = [];
  for (let i = 0; i < rowCount; i++) {
    const row = columns.reduce((acc, column) => {
      switch (column.prop) {
        case "tableName":
          acc[column.prop] = Mock.mock("@ctitle(3, 5)");
          break;
        case "tableNote":
          acc[column.prop] = Mock.mock("@cparagraph(1)");
          break;
        case "className":
          acc[column.prop] = Mock.mock("@ctitle(2, 4)");
          break;
        case "genType":
          acc[column.prop] = Mock.mock(
            '@pick(["自动生成", "手动生成", "导入"])'
          );
          break;
        case "createTime":
          acc[column.prop] = Mock.mock('@datetime("yyyy-MM-dd HH:mm:ss")');
          break;
      }
      return acc;
    }, {});
    data.push(row);
  }
  return data;
};
// 定义接口
export interface fieldTable {
  label: string; //列表显示名称
  prop: string; //字段名称
  showType: string; //详情显示类型
  queryShowType: string; //表头筛选显示类型
  field: string; //数据库字段
  visible: boolean; //是否返回这个字段 fasle不返回这个字段
  queryType: string; //查询方式
  span: number; //表单显示宽度 24为一行
  isAdd: boolean; //是否添加更新
  isEdit: boolean; //是否编辑更新
  sqlType: string; //数据库类型
  componentName: string; //组件名称
  dict: ""; //字典code
}
export const userTableFields: fieldTable[] = [
  {
    label: "用户名",
    prop: "username",
    showType: "text",
    queryShowType: "input",
    dict: "",
    field: "username",
    visible: true,
    queryType: "LIKE",
    span: 12,
    isAdd: true,
    isEdit: true,
    sqlType: "VARCHAR(255)",
    componentName: "ElInput",
  },
  {
    label: "密码",
    prop: "password",
    visible: true,
    dict: "",
    showType: "text",
    isAdd: true,
    queryType: "LIKE",
    componentName: "ElInput",
    queryShowType: "input",
    isEdit: true,
    span: 12,
    field: "password",
    sqlType: "VARCHAR(255)",
  },
  {
    label: "邮箱",
    queryShowType: "input",
    prop: "email",
    showType: "text",
    field: "email",
    isAdd: true,
    componentName: "ElInput",
    queryType: "LIKE",
    span: 12,
    dict: "",
    isEdit: true,
    visible: true,
    sqlType: "VARCHAR(255)",
  },
  {
    label: "注册时间",
    prop: "registerTime",
    queryShowType: "input",
    showType: "text",
    componentName: "ElDatePicker",
    isAdd: true,
    isEdit: true,
    queryType: "LIKE",
    dict: "",
    span: 12,
    visible: true,
    field: "register_time",
    sqlType: "TIMESTAMP",
  },
  {
    label: "用户状态",
    showType: "text",
    queryShowType: "input",
    dict: "",
    prop: "status",
    componentName: "selectDict",
    isAdd: true,
    span: 12,
    queryType: "LIKE",
    isEdit: true,
    visible: true,
    field: "status",
    sqlType: "VARCHAR(255)",
  },
  {
    label: "用户角色",
    queryShowType: "input",
    showType: "text",
    prop: "role",
    componentName: "ElInput",
    isAdd: true,
    queryType: "LIKE",
    span: 12,
    dict: "",
    isEdit: true,
    visible: true,
    field: "role",
    sqlType: "VARCHAR(255)",
  },
  {
    label: "头像",
    componentName: "ElInput",
    showType: "text",
    queryType: "LIKE",
    prop: "avatar",
    isAdd: true,
    dict: "",
    isEdit: true,
    queryShowType: "input",
    visible: true,
    field: "avatar",
    span: 12,
    sqlType: "VARCHAR(500)",
  },
  {
    label: "积分",
    prop: "points",
    visible: true,
    showType: "text",
    queryType: "LIKE",
    componentName: "ElInput",
    isAdd: true,
    queryShowType: "input",
    isEdit: true,
    dict: "",
    field: "points",
    span: 12,
    sqlType: "INT",
  },
  {
    label: "性别",
    prop: "gender",
    showType: "text",
    isAdd: true,
    queryType: "LIKE",
    dict: "",
    componentName: "ElInput",
    span: 12,
    isEdit: true,
    queryShowType: "input",
    field: "gender",
    visible: true,
    sqlType: "VARCHAR(255)",
  },
];
